<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<title>${params.titlename}</title>
<link rel="stylesheet" href="/css/base/${params.prefixs}login.css" />
<script type="text/javascript" src="/js/base/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="/js/base/jquery.cookie.js"></script>
<script type="text/javascript">


$().ready(function(){
	if('${isIE}' != 'true'){
		if (navigator.userAgent.indexOf("Firefox") > 0 || navigator.userAgent.indexOf("Chrome") > 0) {
			
		} else {
			//window.location.href = "/login/error";
		}
	}
	$('#subButton').click(function(){
		var username = $('#username').val();
		var password = $('#password').val();
		var imageCode = $('#imageCode').val();
		if(username == null || username == ''){
			$('#ts').html("请您填写账号！");
			$('#ts').show();
		}else if(password == null || password == ''){
			$('#ts').html("请您填写密码！");
			$('#ts').show();
		}else if(imageCode == null || imageCode == ''){
			$('#ts').html("请您填写验证码！");
			$('#ts').show();
		}else{
			$.post("/login/check",{'username':username,'password':password,'imageCode':imageCode},function(data){
				if(data == 'yes'){
					rmbuser();
					$('#ts').html("登录成功！");
					$('#ts').show();
					$("#subForm").submit();
				}else if(data == 'userError'){
					$('#ts').html("您输入的用户不存在！");
					$('#ts').show();
				}else if(data == 'passwordError'){
					$('#ts').html("输入密码错误，请重新登录！");
					$('#ts').show();
				}else if(data == 'imageCodeError'){
					$('#ts').html("您输入的验证码不正确！");
					$('#ts').show();
				}else if(data == 'typeError'){
					$('#ts').html("用户密码错误~！");
					$('#ts').show();
				}else if(data == 'statusError'){
					$('#ts').html("该用户已被禁用，请联系管理员！");
					$('#ts').show();
				}else if(data == 'adminError'){
					$('#ts').html("后台程序关闭，请联系管理员!");
					$('#ts').show();
				}
			});
		}
	});
	
	if ($.cookie("host") == window.location.host) {
		$("#rmbuser").prop("checked", true);
		$("#username").val($.cookie("username"));
		$("#password").val($.cookie("password"));
	}
});

//enter按键 
$(document).keydown(function (event){
	if(event.keyCode==13){ 
		$('#subButton').click(); 
	}
});

//记住用户名密码
function rmbuser() {
	if ($("#rmbuser").prop("checked")) {
		var username = $("#username").val();
		var password = $("#password").val();
		var host = window.location.host;
		$.cookie("host", host, {
			expires : 7
		}); //存储一个带7天期限的cookie
		$.cookie("username", username, {
			expires : 7
		});
		$.cookie("password", password, {
			expires : 7
		});
	} else {
		$.cookie("host", "host", {
			expire : -1
		});
		$.cookie("username", "", {
			expires : -1
		});
		$.cookie("password", "", {
			expires : -1
		});
	}
};
function refresh(obj) {
    obj.src = "/login/getImage?"+Math.random();
}
function register(){
	$('#ts').html("暂不提供内部员工的注册！");
	$('#ts').show();
}
function forgotPWD(){
	$('#ts').html("请联系管理员");
	$('#ts').show();
}
function hidespan(){
	$('#ts').hide();
}

</script>
</head>
<body>
<div class="bg">
    <img src="../../img/login/${params.prefixs}bg.jpg" alt=""/>
</div>
<div class="main">
	<form action="/login/dologin" method="post" id="subForm">
        <div class="main_out">
            <%-- <a href="${params.homepageurl}">
           	 	<img src="../../img/login/${params.prefixs}logo.png" alt="" class="logo"/>          	 	
            </a>
            <h1 class="main_word">专注互联网程序化购买</h1> --%>
                        
            <h1 class="my_word">ismp</h1>
            
            <p class="down">
               <span id="ts" style="display: none;"></span>
            </p>
            <p class="right">
                <label class="emailicon"></label>
                <input id="username" name="username" onfocus="hidespan()" type="text" placeholder="用户名" class="email"/>
                
            </p>

            <p class="right">
                <label class="passicon"></label>
                <input id="password" type="password" name="password" onfocus="hidespan()" placeholder="密码" class="pass"/>
            </p>

            <p class="right">
                <label class="passtesticon"></label>
                <input id="imageCode" type="text" name="imageCode" onfocus="hidespan()" placeholder="验证码" class="passtest"/>
		        <img class="passtextword" title="点击更换" onclick="javascript:refresh(this);" src="/login/getImage"/>
            </p>
            <p class="right">
                <label>记住用户名</label>
                <input id="rmbuser" type="checkbox" class="rember_user"/>
            </p>
            <p class="right">
                <input type="button" class="LG" value="登 录" id="subButton"/>               
            </p>
            <p  class="right">
            	 <a href="javascript:void(0);" onclick="forgotPWD()" class="fleft" ><i></i>忘记密码？</a>
            	 <a href="javascript:void(0)"  class="fright" onclick="register()">立即注册</a>
            </p>
        </div>
        </form>
</div>
<div class="foot">
    	<a href="#">关于我们</a> <a href="">|</a> <a href="#">联系我们</a> <a href="">|</a>
		<a href="#">服务条款</a> <a href="">|</a> <a href="#">隐私政策</a> <a href="">|</a>
		<a href="#">常见问题</a> <a href="">${params.ispn}</a>
</div>
</body>
</html>